#include <stdio.h>

#include "commons/libar8020.h"

char *textFileRead(char *filename, int *len) {
  char *text;
  FILE *pf = fopen(filename, "r");
  fseek(pf, 0, SEEK_END);
  int lSize = ftell(pf);
  *len = lSize;
  text = (char *)malloc(lSize + 1);
  rewind(pf);
  fread(text, sizeof(char), lSize, pf);
  text[lSize] = '\0';
  return text;
}

int main(int argc, char **argv) {
  if (Usb_Init_So() < 0) {
    printf("error init usb\n");
    return -1;
  }

  int len = 0;
  char *content = textFileRead((char *)"test_face.jpg", &len);
  printf("len = %d\n", len);
  int ret = Img_Port_Send_So(content, len, 2);
  printf("ret = %d\n", ret);

  return 0;
}